<?php

class Rcp_LpImport_EventsImport {
	
	const START_STATE = 0;
	
	public function start() {
		
	}
	
	public function importWorkTime() {
		$sql = "SELECT LpLogo as user_ext_id, Data as date, Czas as time, WW  as io, TB as cp 
						FROM w_vv_rcp_czaspracyext
						WHERE CZAS_IMPORTU BETWEEN '2014-05-14 09:00:00.001' AND '2014-05-15 09:00:00.000'
						ORDER BY Czas ASC";
		$con = Propel::getConnection('vw_lp');
		$stmt = $con->prepare($sql);
		$stmt->execute();
		$lpGroups = $this->buildGroup($stmt->fetchAll(PDO::FETCH_ASSOC));
		foreach ($lpGroups as $userExtId => $lpWorkTimes) {
			$state = self::START_STATE;
			foreach ($lpWorkTimes as $lpWorkTime) {
				switch ($state) {
					case self::START_STATE: 
						$this->processStartState($lpWorkTime);
						break;
				}
			}
		}
	}
	
	private function processStartState() {
		
	}
	
	private function buildGroup($values) {
		$ret = array();
		foreach ($values as $value) {
			$key = $value['user_ext_id'];
			$ret[$key][] = $value;
		}
		return $ret;
	}
	
}